import Vue from "vue";
import Router from "vue-router";
import login from "./components/login.vue";
import cen from "./components/Cen.vue";

import Info from "./components/info.vue";

import biaobai from "./components/biaobai.vue";
import tiewen from "./components/tiewen.vue";
import tucao from "./components/tucao.vue"
// import faceList from "./components/facelist.vue"
// const biaobai = () => import("./components/biaobai.vue");
// const tiewen = () => import("./components/tiewen.vue");
// const tucao = () => import("./components/tucao.vue");
// const faceList =()=>import("./components/facelist.vue")
import Home from "./views/Home.vue";
import market from "./components/Market.vue";
import find from "./components/Find.vue";
import hello from "./components/Hello.vue";
import bag from "./components/Bag.vue";
import lost from "./components/Lost.vue";
// import NewsLists
const NewsLists = () => import("./components/NewsLists.vue");
const NewsContent = () => import("./components/NewsContent.vue");
const xiaozhao = () => import("./components/xiaozhao.vue");

Vue.use(Router);

const router = new Router({
  mode: "history",
  base: process.env.BASE_URL,
  routes: [
    {
      path: "/",
      redirect: "/login",
    },
    {
      path: "/login",
      component: login,
    },
    {
      path: "/info",
      component: Info,
    },

    {
      path: "/home",
      component: Home,
      children: [
        {
          path: "/market",
          component: market,
        },
        {
          path: "/biaobai",
          component: biaobai,
        },
        {
          path: "/tiewen",
          component: tiewen,
        },
        {
          path: "/tucao",
          component: tucao,
        },
        {
          path: "/bag",
          component: bag,
        },
        {
          path: "/find",
          component: find,
        },
        {
          path: "/lost",
          component: lost,
        },

        {
          path: "/index",
          component: cen,
        },

        {
          path: "/NewsLists",
          component: NewsLists,
        },

        {
          path: "/NewsContent",
          component: NewsContent,
        },
        {
          path: "/xiaozhao",
          component: xiaozhao,
        },
      ],
    },
  ],
});
// 导航守卫 保护有权限的页面
// router.beforeEach(function(to, from, next) {
//   // 如果从login页面来 直接放行
//   if (to.path == "/login") {
//     return next();
//   }
//   const tokenStr = window.sessionStorage.getItem("tokenid");
//   // 如果没有token 即没有登录 则返回到登录页面
//   if (!tokenStr) {
//     return next("/login");
//   }
//   next();
// });
export default router;
